//
//  ActVoucherViewController.m
//  ActSistant
//
//  Created by Loan Dinh on 2/23/13.
//

#import "ActVoucherViewController.h"
#import "ActGlobal.h"
#import "ActSettingViewController.h"

@interface ActVoucherViewController ()

@end

@implementation ActVoucherViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.navigationView.btnRight1 addTarget:self action:@selector(doSetting:) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationView.btnBack addTarget:self action:@selector(doBackbarButton:) forControlEvents:UIControlEventTouchUpInside];
}

- (IBAction)doSetting:(id)sender{
    ActSettingViewController *controller = [[ActSettingViewController alloc] initWithNibName:@"ActSettingViewController" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}
-(void)doBackbarButton:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - table view
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 3*tableView.frame.size.height/8-20;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return tableView.frame.size.height/8+20;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier= @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake((cell.frame.size.width-52)/2,(3*tableView.frame.size.height/8-50)/2,40, 30)];
        [iconView setImage:[UIImage imageNamed:@"camera_icon"]];
        [cell.contentView addSubview:iconView];
        [iconView release];
    }
    
    return cell;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, tableView.frame.size.height/8+20)] autorelease];
    [headerView setBackgroundColor:[UIColor clearColor]];
    UILabel* header = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, tableView.frame.size.height/8)];
    [header setBackgroundColor:kColorHeaderTable];
    [header setTextAlignment:UITextAlignmentCenter];
    [header setTextColor:[UIColor whiteColor]];
    [header setFont:UIFontSystemBold(22)];
    if(section == 0){
        [header setText:@"Voucher"];
    }else if(section == 1){
        [header setText:@"Paycheck"];
    }
    [headerView addSubview:header];
    [header release];
    return headerView;
}
- (void)dealloc {
    [_navigationView release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setNavigationView:nil];
    [super viewDidUnload];
}
@end
